#include <QString>
#include <QTextStream>
#include <QCoreApplication>
#include <exiv2/exiv2.hpp>
#include <iostream>
#include <iomanip>
#include <cassert>
using namespace std;


int main1()
{
    std::cout<<"ddd"<<std::endl;
    std::string filepath = "/home/xiaoguo/Codes/c++practics/gps/img.jpg";
    Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(filepath);

    if(image.get() == 0)
        cout<<"failed to read the image..."<<endl;

    image->readMetadata();
    Exiv2::ExifData &exifData = image->exifData();
    if (exifData.empty()) {
        std::cout<<"empty......"<<endl;
    }
    Exiv2::ExifData::const_iterator end = exifData.end();
    for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) {
        const char* tn = i->typeName();
        std::cout << std::setw(44) << std::setfill(' ') << std::left
                  << i->key() << " "
                  << "0x" << std::setw(4) << std::setfill('0') << std::right
                  << std::hex << i->tag() << " "
                  << std::setw(9) << std::setfill(' ') << std::left
                  << (tn ? tn : "Unknown") << " "
                  << std::dec << std::setw(3)
                  << std::setfill(' ') << std::right
                  << i->count() << "  "
                  << std::dec << i->value()
                  << "\n";
    }
    return 0;
}
